﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Web.UI;
using System.Text;

namespace Marbles.Core.Controls
{
    [ToolboxData("<{0}:GoogleGadget runat=server></{0}:GoogleGadget>")]
    public class GoogleGadget : WebControl
    {

        public string Url
        {
            get { object obj = ViewState["Url"]; return (obj == null ? "" : obj.ToString()); }
            set { ViewState["Url"] = value; }
        }


        protected virtual string GetGoogleGadgetScript()
        {
            return string.Format("http://gmodules.com/ig/ifr?url={0}&output=js", this.Url);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            writer.AddAttribute("language", "javascript");
            writer.AddAttribute("src", GetGoogleGadgetScript());
            writer.AddAttribute("type", "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            writer.RenderEndTag();
            base.Render(writer);
        }

    }
}
